home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d7 / csp101.arc / CSP.DOC next >
Encoding:
Text File  |  1991-04-29  |  9.4 KB  |  331 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.                                                                      Page 1
  9.  
  10.  
  11.                                        CSP
  12.                           Preprocessor for SALT Scripts
  13.  
  14.      WHAT IS CSP?
  15.  
  16.      CSP (CS Preprocessor) uses the Microsoft C or QuickC compiler as a
  17.      Telix SALT preprocessor, giving the SALT compiler conditional compile,
  18.      include file, and macro capabilities.
  19.  
  20.      CSP requires Microsoft's QCL.EXE or CL.EXE in one of the directories
  21.      in your PATH.  
  22.  
  23.  
  24.      WHAT DOES IT DO?
  25.  
  26.      Not a whole lot.  It runs a script file (for example FOO.SLT) through
  27.      the Microsoft C compiler (either QCL or CL) with the /P switch to
  28.      create an intermediate file.  The intermediate file is lightly edited,
  29.      then given to the SALT compiler (CS.EXE).  Line references in CS error
  30.      messages are changed from the file and line of the intermediate file
  31.      to the original file and line number.
  32.  
  33.  
  34.      FILES INCLUDED:
  35.  
  36.           CSP.EXE   SALT "preprocessor".
  37.           CSP.DOC   This file.
  38.           CSP.WP5   WordPerfect 5.1 version of this file.
  39.  
  40.  
  41.      HOW DO I USE IT?
  42.  
  43.      The simple syntax is:
  44.  
  45.           CSP sourcefile [outputfile]
  46.  
  47.      Which will preprocess and compile a SALT source file.  SOURCEFILE is
  48.      the name of the script source file.  If no extension is given CSP will
  49.      look for the file with the extension CSP, then SLT.
  50.  
  51.      OUTPUTFILE is the filename (with no extension) CSP is to use when
  52.      creating output files.  If an extension is given it is ignored.  If no
  53.      output name is given then all files are named after the source file.
  54.  
  55.  
  56.      The full syntax is:
  57.  
  58.           CSP [-Q"CMD"] [-PC] [-D MACRO=VALUE]... [-I DIR] [-b]
  59.               [-sstack] sourcefile [outputfile]
  60.  
  61.      switches (which may begin with either '-' or '/') are:
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76.                                                                      Page 2
  77.  
  78.      -Q     Use CMD as preprocessor.
  79.      -P     Preprocess only, do not compile.  Creates a .SLI file.
  80.      -C     Tell C preprocessor not to strip comments.
  81.      -D     Tell C preprocessor to define MACRO as VALUE.
  82.      -I     Tell C preprocessor to search DIRECTORY for include files.
  83.      -l     Compile a C-preprocessed SALT file.
  84.      -b     Compress runs of blank lines to one blank line.
  85.      -e     Send C preprocessor error output to standard output.
  86.      -s     Sets the stack size used by the SALT compiler.
  87.  
  88.  
  89.  
  90.      EXPLANATIONS OF OPTIONS:
  91.  
  92.      -Q     Use CMD as preprocessor.
  93.  
  94.      CSP usually uses either QCL or CL as the C preprocessor.  If you have
  95.      another C compiler that can produce compatible preprocessed output /Q
  96.      will force CSP to use it.  If the command requires switches the whole
  97.      command string must be quoted.  For instance if you want CSP to use CL
  98.      instead of QCL (which it would do anyway if it didn't find QCL but I
  99.      can't think of a better example) use:
  100.  
  101.         CSP -Q"CL /P" FOO.SLT
  102.  
  103.  
  104.      -P     Preprocess only, do not compile.  Creates a .SLI file.
  105.  
  106.      CSP will send the file through the C preprocessor and create a CS-
  107.      compilable SLI file, but will not compile it.
  108.  
  109.  
  110.      -C     Tell C preprocessor not to strip comments.
  111.  
  112.      This passes the "/C" switch to the C preprocessor which tells it not
  113.      to strip comments from the source file.
  114.  
  115.  
  116.      -D     Tell C preprocessor to define MACRO as VALUE.
  117.  
  118.      Each -DMACRO=VALUE used passes a "/DMACRO=VALUE" to the C preprocessor
  119.      to define a macro.
  120.  
  121.  
  122.      -l     Compile a C-preprocessed SALT file.
  123.  
  124.      If you have another C compiler that produces Microsoft-compatible
  125.      preprocessor output, you can preprocess the script first then use CSP
  126.      with the -l switch on the output file.  It will not preprocess the
  127.      file, but will compile it with CS and change line references in CS
  128.      error messages.
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139.  
  140.  
  141.  
  142.  
  143.  
  144.                                                                      Page 3
  145.  
  146.      -b     Compress runs of blank lines to one blank line.
  147.  
  148.      Usually the C preprocessor replaces lines containing preprocessor
  149.      directives and "switched off" code with blank lines.  This option
  150.      replaces multiple blank lines with one blank line, resulting in a more
  151.      presentable SLI file.
  152.  
  153.  
  154.      -e     Send C preprocessor error output to standard output.
  155.  
  156.      This will force the C preprocessor to send all it's messages to the
  157.      standard output, allowing it to be redirected with '>', '>>', and '|'.
  158.  
  159.  
  160.      -s     Sets the stack size used by the SALT compiler.
  161.  
  162.      This option is passed to the SALT compiler to set the stack size of
  163.      the compiled SLC file.
  164.  
  165.      Since you have to have a C compiler to use this I'm assuming you are
  166.      either already familiar with the C preprocessor directives or have
  167.      them documented elsewhere, and they won't be described here. 
  168.      Obviously they work here just as they do in C, since the C compiler is
  169.      doing the preprocessing.  Some notes:
  170.  
  171.      There are a few preprocessor directives that QCL does not remove
  172.      (#pragma for instance), and these are stripped by CSP before the SALT
  173.      compile.  
  174.  
  175.  
  176.      CSP will complain about code like this:
  177.  
  178.           #define FOUR 2+2
  179.           int x=FOUR;
  180.  
  181.      Because neither the C preprocessor nor CS replaces "2+2" with "4", so
  182.      the second line actually evalutes to:
  183.  
  184.           int x=2+2;
  185.  
  186.      and the SALT compiler only allows variable declarations to initialize
  187.      a variable to a constant, not an expression.  If you can't reduce the
  188.      macro to a constant then the the variable must be declared and
  189.      intialized separately:
  190.  
  191.           #define FOUR 2+2
  192.           int x;
  193.           x=FOUR;
  194.  
  195.  
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.  
  203.  
  204.  
  205.  
  206.  
  207.  
  208.  
  209.  
  210.  
  211.  
  212.                                                                      Page 4
  213.  
  214.      Because the C preprocessor strips comments by default, SALT scripts
  215.      that are preprocessed with CSP can contain C-style "/* */" comments,
  216.      as long as the -C switch is not used.
  217.  
  218.  
  219.      DISCLAIMER:
  220.  
  221.      CSP is provided on an "as is" basis without warranty of any kind,
  222.      expressed or implied, including but not limited to the implied
  223.      warranties of merchantability and fitness for a particular purpose.
  224.      The person using the software bears all risk as to the quality and
  225.      performance of the software.  Should the software prove defective, the
  226.      user assumes the entire cost of all necessary repair, servicing, or
  227.      correction.  The author will not be liable for any special,
  228.      incidental, consequential, indirect or  similar damages due to loss of
  229.      data or any other reason, even if the author or an agent of the author
  230.      has been advised of the possibility of such damages.  In no event
  231.      shall the author's liability for any damages ever exceed the price
  232.      paid for the license to use the software, regardless of the form of
  233.      the claim.
  234.  
  235.      REVISION HISTORY:
  236.  
  237.      Version 1.01, April 15:
  238.  
  239.           Added search for files with CSP and SLT extensions.
  240.  
  241.           Filenames and line numbers in CS "warning" messages were not
  242.           being changed to the original file and line number.  Fixed.
  243.  
  244.      Version 1.00, March 16, 1991:  Initial release.
  245.  
  246.  
  247.      ANYTHING ELSE?
  248.  
  249.      There is no charge for private, non-commercial use of CSP (but if you
  250.      send a check anyway it won't go uncashed).  If you use CSP in the
  251.      development of scripts which are sold to others, a $10 registration is
  252.      required.  Comments, suggestions, and requests can be left at:
  253.  
  254.             The Dead of Night BBS
  255.             (703) 644-7667
  256.  
  257.      or mailed to:
  258.  
  259.             Donald Mehrtens
  260.             5923 Minuteman Rd
  261.             Springfield VA 22152
  262.  
  263.      or sent via CompuServe (which I don't check very often) to ID
  264.      72361,1407.
  265.  
  266.  
  267.  
  268.  
  269.  
  270.  
  271.  
  272.  
  273.  
  274.  
  275.  
  276.  
  277.  
  278.  
  279.  
  280.                                                                      Page 5
  281.  
  282.      SALT Programmers, HELP!
  283.  
  284.      Is there any way for a script to determine its own name, as DOS batch
  285.      files can do with %0 or C programs can do with argv[0]?
  286.  
  287.      Can a script find out how many and/or what types of arguments the
  288.      main () function was actually passed, so that a script that needs
  289.      arguments can GRACEFULLY exit if it wasn't given any?  Is there
  290.      something similar to C's argc?
  291.  
  292.      As of v3.15 (possibly sooner) the SALT compiler has a "void" keyword. 
  293.      What does it do?
  294.  
  295.      Some scripts run considerably slower if _scr_chk_key is set to 0 to
  296.      disable the ESC key from prompting to abort the script.  Can anything
  297.      be done about this?  Can the ESC key be prevented from aborting
  298.      scripts without using _scr_chk_key?
  299.  
  300.      Is there any way to find out whether the cursor is on or off?
  301.  
  302.      Is there a cleaner way to find out if the status bar is on than to
  303.      look on the screen for it with vgetchr/vgetstr?
  304.  
  305.      Is there a way to see if a local key has been hit without destroying
  306.      the terminal() function's ability to process it, like cinp_count()
  307.      does with the comm port?
  308.  
  309.      Despite the fact that Telix does not appear able to do anything with
  310.      it, CS will happily compile a script that has no main() function.  Is
  311.      this of any use?
  312.  
  313.      Can a script find out which dialing directory entries are marked?  Can
  314.      a script mark and unmark entries?
  315.  
  316.      And does ANYBODY know ANYTHING about Telix 4.0?
  317.  
  318.  
  319.  
  320.  
  321.  
  322.  
  323.  
  324.  
  325.  
  326.  
  327.  
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334.  
  335.  
  336.  
  337.  
  338.  
  339.  
  340.  
  341.